import { createApp } from "vue";
import App from "./App.vue";
import router from "../router";  // 确保这个路径是正确的
import { createVuetify } from "vuetify";
import * as components from "vuetify/components";
import * as directives from "vuetify/directives";
import "vuetify/styles";
import "@mdi/font/css/materialdesignicons.css";

import "../styles/main.css";

console.log("Initializing Vue app");

const vuetify = createVuetify({
  components,
  directives,
});

const app = createApp(App);

app.config.errorHandler = (err, vm, info) => {
  console.error("全局错误:", err);
  console.error("错误信息:", info);
};

router.onError((error) => {
  console.error("路由错误:", error);
});

console.log("路由配置:", router.options.routes);

router.beforeEach((to, from, next) => {
  console.log("Navigation to:", to);
  console.log("Navigation from:", from);
  next();
});

app.use(router);
app.use(vuetify);

router.isReady().then(() => {
  app.mount("#app");
  console.log("Vue app mounted");
});
